package top.moonkit.rs_pro.entity.vo;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

import java.io.Serializable;

/**
 * 分页请求参数
 * @author moon
 * @since
 */
@Data
public class PageRequestVO implements Serializable {

    private static final long serialVersionUID = 1L;
    private Integer pageNum;
    private Integer pageSize;
    private String sortField;
    private String sortType;


    public Integer getPageNum() {
        return pageNum == null  || pageNum < 1 ? 1 : pageNum;
    }

    public Integer getPageSize() {
        return pageSize == null || pageSize < 1 ? 10 : pageSize;
    }

    public String getSortType() {
        if (StrUtil.isBlank(sortType)){
            return null;
        }else if("desc".equalsIgnoreCase(sortType)){
            return "desc";
        }else if ("asc".equalsIgnoreCase(sortType)){
            return "asc";
        }else{
            return null;
        }
    }

}
